package org.example.xx2.controller;

import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(MethodArgumentNotValidException.class)
    public String handleValidationException(MethodArgumentNotValidException ex) {
        ex.printStackTrace(); // 打印详细异常堆栈
        System.out.println("参数校验失败: " + ex.getMessage());
        return "参数校验失败: " + ex.getMessage();
    }
} 